package com.github.hwangrq.myrpc.provider.myrpc.provider;

import com.github.hwangrq.myrpc.provider.myrpc.provider.server.RpcServer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class MyRpcProviderApplication implements CommandLineRunner {

    @Autowired
    private RpcServer rpcServer;

    public static void main(String[] args) {
        SpringApplication.run(MyRpcProviderApplication.class, args);
    }

    @Override
    public void run(String... args) throws Exception {
        new Thread(() -> {
            rpcServer.startServer("127.0.0.1", 9901);
        }).start();
        new Thread(() -> {
            rpcServer.startServer("127.0.0.1", 9902);
        }).start();
        new Thread(() -> {
            rpcServer.startServer("127.0.0.1", 9903);
        }).start();
    }
}
